package com.develop.data.loan.jpa.attribute.converter;

import com.develop.data.loan.option.constraint.CodedOption;
import lombok.NoArgsConstructor;

import javax.persistence.AttributeConverter;

@NoArgsConstructor
public class CodedEnumAttributeConverterFactory  {
    
    public <OptionType extends Enum<?> & CodedOption> CodedEnumAttributeConverter<OptionType> getCodedEnumAttributeConverter(Class<OptionType> targetType) {
        return new CodedEnumAttributeConverter<OptionType>(targetType);
    }

    public <OptionType extends Enum<?> & CodedOption> AttributeConverter<OptionType, String> getAttributeConverter(Class<OptionType> targetType) {
        return new CodedEnumAttributeConverter<OptionType>(targetType);
    }

    public static <OptionType extends Enum<?> & CodedOption> Class<?> generateCodedEnumAttributeConverter(Class<OptionType> targetType){
        CodedEnumAttributeConverterGenerator generator = new CodedEnumAttributeConverterGenerator();
        return generator.generate(targetType);
    }
}

